package com.manager.devicemanager.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.manager.devicemanager.common.Result;
import com.manager.devicemanager.entity.Board1;
import com.manager.devicemanager.entity.RealTimeStatusTemplate;
import com.manager.devicemanager.service.IRealTimeStatusTemplateService;
import com.manager.devicemanager.vo.PageVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wpf
 * @since 2025-05-29
 */
@RestController
@RequestMapping("/realTimeStatusTemplate")
public class RealTimeStatusTemplateController {
    @Autowired
    private IRealTimeStatusTemplateService  realTimeStatusTemplateService;
    /**
     * 带条件筛选的分页查询接口
     * @param pageVO 分页查询条件对象，包含页码、每页数量和查询条件
     * @return 分页查询结果
     * */
    @Operation(summary = "带条件筛选的分页查询")
    @PostMapping("/page")
    public Result<IPage<RealTimeStatusTemplate>> page(
            @Parameter(description = "分页查询条件对象")
            @RequestBody PageVO<RealTimeStatusTemplate> pageVO) {
        // 获取分页参数
        int pageNum = pageVO.getPageNum();
        int pageSize = pageVO.getPageSize();
        // 获取查询条件
        RealTimeStatusTemplate condition = pageVO.getCondition();

        // 构建查询条件包装器
        LambdaQueryWrapper<RealTimeStatusTemplate> queryWrapper = new LambdaQueryWrapper<>(condition);

        // 执行分页查询
        IPage<RealTimeStatusTemplate> pageResult = realTimeStatusTemplateService.page(
                new Page<>(pageNum, pageSize), queryWrapper);

        return Result.success(pageResult);
    }

}
